<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-50TX445NDJ"></script>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}

    // Set default consent for ad and analytics storage.
    gtag('consent', 'default', {
        'ad_storage': 'denied',
        'analytics_storage': 'denied',
        'wait_for_update': 500  // milliseconds
    });

    // Now load GA
    gtag('js', new Date());
    gtag('config', 'G-50TX445NDJ',{ 'anonymize_ip': true });
</script>

<!-- load Osano -->
<script src="https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.js"></script>
<script>
    window.cookieconsent.initialise({
        palette: {
            popup: {
                background: "#ebeeee",
                text: "#161515"
            },
            button: {
                background: "#003e74",
                text: "#fff"
            }
        },
        type: "opt-in",
        law: "EU",
        revokable: "true",
        dismissOnScroll: 100,
        dismissOnTimeout: 10000,
        dismissOnWindowClick: "true",
        content: {
            message: "KiCad uses cookies to improve our website for you."
        },
        onInitialise: function (status) {
            var type = this.options.type;
            var didConsent = this.hasConsented();
            if (type == 'opt-in' && didConsent) {
                gtag('consent', 'update', {'analytics_storage': 'granted'});
            }
            if (type == 'opt-out' && !didConsent) {
                gtag('consent', 'update', {'analytics_storage': 'denied'});
            }
        },
        onStatusChange: function(status) {
            var type = this.options.type;
            var didConsent = this.hasConsented();
            if (type == 'opt-in' && didConsent) {
                gtag('consent', 'update', {'analytics_storage': 'granted'});
            }
            if (type == 'opt-out' && !didConsent) {
                gtag('consent', 'update', {'analytics_storage': 'denied'});
            }
        },
        onRevokeChoice: function() {
            var type = this.options.type;
            if (type == 'opt-in') {
                gtag('consent', 'update', {'analytics_storage': 'denied'});
            }
            if (type == 'opt-out') {
                gtag('consent', 'update', {'analytics_storage': 'granted'});
            }
        }
    });
</script>